home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWShpLst.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  5.7 KB  |  224 lines  |  [TEXT/MPS ]

  1. #ifndef FWSHPLST_H
  2. #define FWSHPLST_H
  3.  
  4. //========================================================================================
  5. //
  6. //    File:                FWShpLst.h
  7. //    Release Version:    $ 1.0d11 $
  8. //
  9. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. // ----- Foundation Includes -----
  14.  
  15. #ifndef FWAUTODE_H
  16. #include <FWAutoDe.h>
  17. #endif
  18.  
  19. // ----- OS Includes
  20.  
  21. #ifndef FWGROBJ_H
  22. #include "FWGrObj.h"
  23. #endif
  24.  
  25. // ----- OpenDoc Includes -----
  26.  
  27. #ifdef _ODTYPES_
  28. #include <ODTypes.h>
  29. #endif
  30.  
  31. #if FW_LIB_EXPORT_PRAGMAS
  32. #pragma lib_export on
  33. #endif
  34.  
  35. //========================================================================================
  36. //    Forward Declarations
  37. //========================================================================================
  38.  
  39. class FW_CLASS_ATTR FW_CGraphicContext;
  40. class FW_CLASS_ATTR FW_CPoint;
  41. class FW_CLASS_ATTR FW_CRect;
  42. class FW_CLASS_ATTR FW_CShape;
  43.  
  44. class FW_CLASS_ATTR FW_PShapeList;
  45. class FW_CLASS_ATTR FW_CShapeListRep;
  46.  
  47. class FW_CLASS_ATTR FW_CShapeListIterator;
  48.  
  49. class FW_CPrivShapeListNode;        // Private class; no "FW_CLASS_ATTR"
  50.  
  51. //========================================================================================
  52. //    class FW_PShapeList
  53. //========================================================================================
  54.  
  55. class FW_CLASS_ATTR FW_PShapeList : public FW_CGraphicCountedPtr
  56. {
  57. public:
  58.     FW_DECLARE_CLASS
  59.  
  60. public:
  61.     FW_PShapeList();
  62.     FW_PShapeList(FW_CShapeListRep* rep);
  63.     FW_PShapeList(FW_CReadableStream& archive);
  64.     virtual ~FW_PShapeList();
  65.     
  66.     FW_PShapeList(const FW_PShapeList& other);
  67.     FW_PShapeList& operator=(const FW_PShapeList& other);
  68.         
  69.     FW_CShapeListRep* operator->();
  70.     const FW_CShapeListRep* operator->() const;
  71. };
  72.  
  73. //----------------------------------------------------------------------------------------
  74. // FW_PShapeList::operator->
  75. //----------------------------------------------------------------------------------------
  76.  
  77. inline FW_CShapeListRep* FW_PShapeList::operator->()
  78. {
  79.     return (FW_CShapeListRep*) GetRep();
  80. }
  81.     
  82. //----------------------------------------------------------------------------------------
  83. // FW_PShapeList::operator->
  84. //----------------------------------------------------------------------------------------
  85.  
  86. inline const FW_CShapeListRep* FW_PShapeList::operator->() const
  87. {
  88.     return (const FW_CShapeListRep*) GetRep();
  89. }
  90.  
  91. //========================================================================================
  92. //    class FW_CShapeListRep
  93. //========================================================================================
  94.  
  95. class FW_CLASS_ATTR FW_CShapeListRep : public FW_CGraphicCountedPtrRep
  96. {
  97. public:
  98.     FW_DECLARE_CLASS
  99.     
  100.     friend FW_CShapeListIterator;
  101.  
  102. //----------------------------------------------------------------------------------------
  103. //    Constructors/Destructors
  104. //
  105.  
  106. public:
  107.  
  108.                         FW_CShapeListRep();
  109.                         FW_CShapeListRep(const FW_CShapeListRep& other);
  110.                         FW_CShapeListRep(FW_CReadableStream& archive);
  111.     virtual            ~FW_CShapeListRep();
  112.  
  113. //----------------------------------------------------------------------------------------
  114. //    Inherited API
  115. //
  116. public:
  117.     virtual void            Flatten(FW_CWritableStream& archive) const;
  118.     virtual FW_Boolean        IsEqual(const FW_CGraphicCountedPtrRep* other) const;
  119.  
  120. //----------------------------------------------------------------------------------------
  121. //    New API
  122. //
  123.  
  124.     // ----- Adding shapes
  125.     
  126.     void            AdoptAtFront(FW_CShape* shape);
  127.     void            AdoptAtBack(FW_CShape* shape);
  128.     void            AdoptAfter(FW_CShape* shapeToAdd, FW_CShape* afterWhich);
  129.     void            AdoptBefore(FW_CShape* shapeToAdd, FW_CShape* beforeWhich);
  130.  
  131.     // ----- Removing shapes
  132.  
  133.     void            Remove(FW_CShape* shape);
  134.     void            RemoveAll();
  135.     FW_CShape*        RemoveTop();
  136.     FW_CShape*        RemoveBottom();
  137.  
  138.     // ----- List operations
  139.  
  140.     FW_Boolean        Contains(FW_CShape* shape) const;
  141.     unsigned long    GetCount() const;
  142.     void            Purge();
  143.     
  144.     // ----- Z-Order methods
  145.     
  146.     FW_Boolean        MoveForward(FW_CShape* shape);
  147.     FW_Boolean        MoveToFront(FW_CShape* shape);
  148.         
  149.     FW_Boolean        MoveBack(FW_CShape* shape);
  150.     FW_Boolean        MoveToBack(FW_CShape* shape);
  151.     
  152.     // ----- Copying
  153.     
  154.     FW_PShapeList    Copy() const;
  155.  
  156.     // ----- Archiving
  157.  
  158.     static void*    Read(FW_CReadableStream& archive);
  159.  
  160. //----------------------------------------------------------------------------------------
  161. //    Implementation
  162. //
  163.  
  164. private:
  165.     FW_CPrivShapeListNode*        fHead;
  166.     FW_CPrivShapeListNode*        fTail;
  167.     unsigned long                fCount;
  168.     
  169.     FW_CPrivShapeListNode*        FindNode(FW_CShape* shape) const;
  170. };
  171.  
  172. //========================================================================================
  173. //    class FW_CShapeListIterator
  174. //========================================================================================
  175.  
  176. class FW_CLASS_ATTR FW_CShapeListIterator FW_AUTO_DESTRUCT_OBJECT
  177. {
  178. public:
  179.     FW_DECLARE_CLASS
  180.     
  181. //----------------------------------------------------------------------------------------
  182. //    Constructors/Destructors
  183. //
  184.     enum EDirection
  185.     {
  186.         kFrontToBack,        // Z-order
  187.         kBackToFront
  188.     };
  189.  
  190.  
  191.     FW_CShapeListIterator(EDirection direction, const FW_PShapeList& shapeList);
  192.     FW_CShapeListIterator(EDirection direction, const FW_CShapeListRep* shapeListRep);
  193.     virtual ~FW_CShapeListIterator();
  194.  
  195. //----------------------------------------------------------------------------------------
  196. //    Iteration
  197. //
  198.  
  199.     FW_CShape*        First();
  200.     FW_CShape*        Next();
  201.  
  202.     FW_Boolean        IsNotComplete() const;
  203.  
  204. //----------------------------------------------------------------------------------------
  205. //    Implementation
  206. //
  207.  
  208. private:
  209.     FW_CPrivShapeListNode*    fFirst;
  210.     FW_CPrivShapeListNode*    fPastLast;
  211.     FW_CPrivShapeListNode*    fCurrent;
  212.     EDirection                fDirection;
  213.     
  214.     void                    CommonInit(EDirection direction,
  215.                                        FW_CPrivShapeListNode* head,
  216.                                        FW_CPrivShapeListNode* tail);
  217. };
  218.  
  219. #if FW_LIB_EXPORT_PRAGMAS
  220. #pragma lib_export off
  221. #endif
  222.  
  223. #endif // FWSHPLST_H
  224.